﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Soothe;
using System.Collections.Generic;

namespace Soothe.Test
{
    [TestClass]
    public class UnitTest1
    {
        const int _estimatedHours = 16;

        private TestContext testContextInstance;

        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [TestMethod]
        public void GenerateFakeHistory()
        {
            var _history = new HistoryOfVelocities();

            _history.GenerateFakeHistory();

            Assert.AreEqual(1000, _history.Count);

            _history.Sort();

            foreach (var task in _history)
                this.testContextInstance.WriteLine(task.Velocity.ToString());
        }

        [TestMethod]
        public void RandomHistory()
        {
            var _history = new HistoryOfVelocities();

            _history.GenerateFakeHistory();

            PrivateObject obj = new PrivateObject(_history);

            var _randomHistory = obj.Invoke("_randomCompletedTasks") as List<CompletedTask>;

            Assert.AreEqual(100, _randomHistory.Count);

            _randomHistory.Sort();

            foreach (var task in _randomHistory)
                this.testContextInstance.WriteLine(task.Velocity.ToString());
        }

        [TestMethod]
        public void SimulateTheFuture()
        {
            var _history = new HistoryOfVelocities();

            _history.GenerateFakeHistory();

            var probabilities = _history.SimulateTheFuture(_estimatedHours);

            Assert.AreEqual(100, probabilities.Count);

            probabilities.Sort();

            foreach (var probability in probabilities)
                this.testContextInstance.WriteLine(probability.ToString());
        }

        [TestMethod]
        public void ProbabilityDensities()
        {
            var _history = new HistoryOfVelocities();

            _history.GenerateFakeHistory();

            var probabilities = _history.SimulateTheFuture(_estimatedHours);

            var probabilityDensities = _history.ProbabilityDensities(probabilities);

            Assert.IsNotNull(probabilityDensities);

            this.testContextInstance.WriteLine("{0}/{1}", probabilityDensities.Count.ToString(), probabilities.Count.ToString());

            foreach (var probability in probabilityDensities)
                this.testContextInstance.WriteLine(probability.ToString());
        }
    }
}
